export default {
    name: 'AddDialog',
    props: {
        sceneProspectFlag: Boolean
    },
    data() {
        let validateuserPhone = (rule, value, callback) => {
            console.log(rule);
            if (value === '') {
                callback(new Error('请输入手机号码'));
            } else {
                callback();
            }
        };
        let validateuserName = (rule, value, callback) => {
            console.log(rule);
            if (value === '') {
                callback(new Error('请输入姓名'));
            } else {
                callback();
            }
        };
        return {
            accountForm: {
                userPhone: '',
                userName: ''
            },
            accontRules: {
                // 供应商手机号
                userPhone: [{ validator: validateuserPhone, trigger: 'blur' }],
                // 姓名
                userName: [{ validator: validateuserName, trigger: 'blur' }]
            }
        };
    },
    methods: {
        // 提交
        async submitDialog() {
            this.$httpExt()
                .post('/api/pmsSupplierAccount/add', {
                    userPhone: this.accountForm.userPhone,
                    userName: this.accountForm.userName
                })
                .then(
                    response => {
                        console.log('返回值', response.data);
                        this.$message({
                            message: '密码已发送至手机',
                            type: 'success'
                        });
                        this.$emit('closeDialog');
                    },
                    response => {
                        Notification.error({
                            title: '异常',
                            message: response.msg
                        });
                    }
                );
        },
        clonseDialog() {
            this.$emit('closeDialog');
        }
    }
};
